home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / 17 controls / databindingdemo / dataset1.vb < prev    next >
Encoding:
Text File  |  2001-10-21  |  10.8 KB  |  302 lines

  1. '------------------------------------------------------------------------------
  2. ' <autogenerated>
  3. '     This code was generated by a tool.
  4. '     Runtime Version: 1.0.2914.16
  5. '
  6. '     Changes to this file may cause incorrect behavior and will be lost if 
  7. '     the code is regenerated.
  8. ' </autogenerated>
  9. '------------------------------------------------------------------------------
  10.  
  11. Option Strict Off
  12. Option Explicit On
  13.  
  14. Imports System
  15. Imports System.Data
  16. Imports System.Runtime.Serialization
  17. Imports System.Xml
  18.  
  19.  
  20. <Serializable(),  _
  21.  System.ComponentModel.DesignerCategoryAttribute("code")>  _
  22. Public Class DataSet1
  23.     Inherits System.Data.DataSet
  24.     
  25.     Private tableAuthors As AuthorsDataTable
  26.     
  27.     Public Sub New()
  28.         MyBase.New
  29.         Me.InitClass
  30.     End Sub
  31.     
  32.     Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
  33.         MyBase.New
  34.         Me.InitClass
  35.         Me.GetSerializationData(info, context)
  36.     End Sub
  37.     
  38.     <System.ComponentModel.Browsable(false),  _
  39.      System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)>  _
  40.     Public ReadOnly Property Authors As AuthorsDataTable
  41.         Get
  42.             Return Me.tableAuthors
  43.         End Get
  44.     End Property
  45.     
  46.     Protected Overrides Function ShouldSerializeTables() As Boolean
  47.         Return false
  48.     End Function
  49.     
  50.     Protected Overrides Function ShouldSerializeRelations() As Boolean
  51.         Return false
  52.     End Function
  53.     
  54.     Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
  55.         Me.ReadXml(reader, XmlReadMode.IgnoreSchema)
  56.     End Sub
  57.     
  58.     Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
  59.         Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
  60.         Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
  61.         stream.Position = 0
  62.         Return System.Xml.Schema.XmlSchema.Read(New XmlTextReader(stream), Nothing)
  63.     End Function
  64.     
  65.     Private Sub InitClass()
  66.         Me.DataSetName = "DataSet1"
  67.         Me.Namespace = "http://www.tempuri.org/DataSet1.xsd"
  68.         Me.tableAuthors = New AuthorsDataTable
  69.         Me.Tables.Add(Me.tableAuthors)
  70.     End Sub
  71.     
  72.     Private Function ShouldSerializeAuthors() As Boolean
  73.         Return false
  74.     End Function
  75.     
  76.     Public Delegate Sub AuthorsRowChangeEventHandler(ByVal sender As Object, ByVal e As AuthorsRowChangeEvent)
  77.     
  78.     Public Class AuthorsDataTable
  79.         Inherits DataTable
  80.         Implements System.Collections.IEnumerable
  81.         
  82.         Private columnAu_ID As DataColumn
  83.         
  84.         Private columnAuthor As DataColumn
  85.         
  86.         Private columnYear_Born As DataColumn
  87.         
  88.         Friend Sub New()
  89.             MyBase.New("Authors")
  90.             Me.InitClass
  91.         End Sub
  92.         
  93.         <System.ComponentModel.Browsable(false)>  _
  94.         Public ReadOnly Property Count As Integer
  95.             Get
  96.                 Return Me.Rows.Count
  97.             End Get
  98.         End Property
  99.         
  100.         Friend ReadOnly Property Au_IDColumn As DataColumn
  101.             Get
  102.                 Return Me.columnAu_ID
  103.             End Get
  104.         End Property
  105.         
  106.         Friend ReadOnly Property AuthorColumn As DataColumn
  107.             Get
  108.                 Return Me.columnAuthor
  109.             End Get
  110.         End Property
  111.         
  112.         Friend ReadOnly Property Year_BornColumn As DataColumn
  113.             Get
  114.                 Return Me.columnYear_Born
  115.             End Get
  116.         End Property
  117.         
  118.         Public Default ReadOnly Property Item(ByVal index As Integer) As AuthorsRow
  119.             Get
  120.                 Return CType(Me.Rows(index),AuthorsRow)
  121.             End Get
  122.         End Property
  123.         
  124.         Public Event AuthorsRowChanged As AuthorsRowChangeEventHandler
  125.         
  126.         Public Event AuthorsRowChanging As AuthorsRowChangeEventHandler
  127.         
  128.         Public Event AuthorsRowDeleted As AuthorsRowChangeEventHandler
  129.         
  130.         Public Event AuthorsRowDeleting As AuthorsRowChangeEventHandler
  131.         
  132.         Public Overloads Sub AddAuthorsRow(ByVal row As AuthorsRow)
  133.             Me.Rows.Add(row)
  134.         End Sub
  135.         
  136.         Public Overloads Function AddAuthorsRow(ByVal Author As String, ByVal Year_Born As Short) As AuthorsRow
  137.             Dim rowAuthorsRow As AuthorsRow = CType(Me.NewRow,AuthorsRow)
  138.             rowAuthorsRow.ItemArray = New Object() {Nothing, Author, Year_Born}
  139.             Me.Rows.Add(rowAuthorsRow)
  140.             Return rowAuthorsRow
  141.         End Function
  142.         
  143.         Public Function FindByAu_ID(ByVal Au_ID As Integer) As AuthorsRow
  144.             Return CType(Me.Rows.Find(New Object() {Au_ID}),AuthorsRow)
  145.         End Function
  146.         
  147.         Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
  148.             Return Me.Rows.GetEnumerator
  149.         End Function
  150.         
  151.         Private Sub InitClass()
  152.             Me.columnAu_ID = New DataColumn("Au_ID", GetType(System.Int32), "", System.Data.MappingType.Element)
  153.             Me.columnAu_ID.AutoIncrement = true
  154.             Me.columnAu_ID.AllowDBNull = false
  155.             Me.columnAu_ID.Unique = true
  156.             Me.Columns.Add(Me.columnAu_ID)
  157.             Me.columnAuthor = New DataColumn("Author", GetType(System.String), "", System.Data.MappingType.Element)
  158.             Me.Columns.Add(Me.columnAuthor)
  159.             Me.columnYear_Born = New DataColumn("Year Born", GetType(System.Int16), "", System.Data.MappingType.Element)
  160.             Me.Columns.Add(Me.columnYear_Born)
  161.             Me.PrimaryKey = New DataColumn() {Me.columnAu_ID}
  162.         End Sub
  163.         
  164.         Public Function NewAuthorsRow() As AuthorsRow
  165.             Return CType(Me.NewRow,AuthorsRow)
  166.         End Function
  167.         
  168.         Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
  169.             'We need to ensure that all Rows in the tabled are typed rows.
  170.             'Table calls newRow whenever it needs to create a row.
  171.             'So the following conditions are covered by Row newRow(Record record)
  172.             '* Cursor calls table.addRecord(record) 
  173.             '* table.addRow(object[] values) calls newRow(record)    
  174.             Return New AuthorsRow(builder)
  175.         End Function
  176.         
  177.         Protected Overrides Function GetRowType() As System.Type
  178.             Return GetType(AuthorsRow)
  179.         End Function
  180.         
  181.         Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
  182.             MyBase.OnRowChanged(e)
  183.             If (Not (Me.AuthorsRowChangedEvent) Is Nothing) Then
  184.                 RaiseEvent AuthorsRowChanged(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
  185.             End If
  186.         End Sub
  187.         
  188.         Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
  189.             MyBase.OnRowChanging(e)
  190.             If (Not (Me.AuthorsRowChangingEvent) Is Nothing) Then
  191.                 RaiseEvent AuthorsRowChanging(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
  192.             End If
  193.         End Sub
  194.         
  195.         Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
  196.             MyBase.OnRowDeleted(e)
  197.             If (Not (Me.AuthorsRowDeletedEvent) Is Nothing) Then
  198.                 RaiseEvent AuthorsRowDeleted(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
  199.             End If
  200.         End Sub
  201.         
  202.         Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
  203.             MyBase.OnRowDeleting(e)
  204.             If (Not (Me.AuthorsRowDeletingEvent) Is Nothing) Then
  205.                 RaiseEvent AuthorsRowDeleting(Me, New AuthorsRowChangeEvent(CType(e.Row,AuthorsRow), e.Action))
  206.             End If
  207.         End Sub
  208.         
  209.         Public Sub RemoveAuthorsRow(ByVal row As AuthorsRow)
  210.             Me.Rows.Remove(row)
  211.         End Sub
  212.     End Class
  213.     
  214.     Public Class AuthorsRow
  215.         Inherits DataRow
  216.         
  217.         Private tableAuthors As AuthorsDataTable
  218.         
  219.         Friend Sub New(ByVal rb As DataRowBuilder)
  220.             MyBase.New(rb)
  221.             Me.tableAuthors = CType(Me.Table,AuthorsDataTable)
  222.         End Sub
  223.         
  224.         Public Property Au_ID As Integer
  225.             Get
  226.                 Return CType(Me(Me.tableAuthors.Au_IDColumn),Integer)
  227.             End Get
  228.             Set
  229.                 Me(Me.tableAuthors.Au_IDColumn) = value
  230.             End Set
  231.         End Property
  232.         
  233.         Public Property Author As String
  234.             Get
  235.                 Try 
  236.                     Return CType(Me(Me.tableAuthors.AuthorColumn),String)
  237.                 Catch e As InvalidCastException
  238.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  239.                 End Try
  240.             End Get
  241.             Set
  242.                 Me(Me.tableAuthors.AuthorColumn) = value
  243.             End Set
  244.         End Property
  245.         
  246.         Public Property Year_Born As Short
  247.             Get
  248.                 Try 
  249.                     Return CType(Me(Me.tableAuthors.Year_BornColumn),Short)
  250.                 Catch e As InvalidCastException
  251.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  252.                 End Try
  253.             End Get
  254.             Set
  255.                 Me(Me.tableAuthors.Year_BornColumn) = value
  256.             End Set
  257.         End Property
  258.         
  259.         Public Function IsAuthorNull() As Boolean
  260.             Return Me.IsNull(Me.tableAuthors.AuthorColumn)
  261.         End Function
  262.         
  263.         Public Sub SetAuthorNull()
  264.             Me(Me.tableAuthors.AuthorColumn) = System.Convert.DBNull
  265.         End Sub
  266.         
  267.         Public Function IsYear_BornNull() As Boolean
  268.             Return Me.IsNull(Me.tableAuthors.Year_BornColumn)
  269.         End Function
  270.         
  271.         Public Sub SetYear_BornNull()
  272.             Me(Me.tableAuthors.Year_BornColumn) = System.Convert.DBNull
  273.         End Sub
  274.     End Class
  275.     
  276.     Public Class AuthorsRowChangeEvent
  277.         Inherits EventArgs
  278.         
  279.         Private eventRow As AuthorsRow
  280.         
  281.         Private eventAction As System.Data.DataRowAction
  282.         
  283.         Public Sub New(ByVal row As AuthorsRow, ByVal action As DataRowAction)
  284.             MyBase.New
  285.             Me.eventRow = row
  286.             Me.eventAction = action
  287.         End Sub
  288.         
  289.         Public ReadOnly Property Row As AuthorsRow
  290.             Get
  291.                 Return Me.eventRow
  292.             End Get
  293.         End Property
  294.         
  295.         Public ReadOnly Property Action As DataRowAction
  296.             Get
  297.                 Return Me.eventAction
  298.             End Get
  299.         End Property
  300.     End Class
  301. End Class
  302.